package com.hrc.rpc.netty.handler.consumer;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;


public class RpcResponseHandler extends SimpleChannelInboundHandler<String> {

    @Override
    protected void channelRead0(ChannelHandlerContext ctx, String msg) {
        System.out.println(msg);
    }

    @Override
    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
        if (cause != null && cause.getMessage().contains("远程主机强迫关闭了一个现有的连接")) {
            System.out.println(ctx.channel().remoteAddress() + "断开连接");
        }
    }
}
